<template>
  <div>
    <el-row :gutter='20' style="padding:40px;">
      <el-col :span="4" v-for="(item,index) in datalist" :key="index">
        <el-card shadow="hover" style="">
          <div slot="header" class="clearfix" style="padding:0.3rem">
            <el-button style="float: left; padding: 3px 0" v-if="item.chakan" @click="updowd(item)" type="text">查看
            </el-button>
            <el-button style="float: right; padding: 3px 0" v-if="item.daochu" type="text" @click="updowd2(item)">导出
            </el-button>
            <el-button style="float: right; padding: 3px 0" v-if="item.bxy" type="text" @click="updowd3(item)">导出
            </el-button>
          </div>
          <img :src="exl" alt="" style="width:60px;height:70px;">
          <p style="width:65%;float:right;font-size:16px;line-height:40px">{{ item.name }}</p>
        </el-card>
      </el-col>
    </el-row>
    <el-dialog :close-on-click-modal='false' :title="item2.name" center :visible.sync="shoujulogdeposit3">
      <el-form>
        <el-form-item label="开始日期">
          <el-date-picker type="date" placeholder="选择日期" v-model="start_time" style="width: 100%;"
                          format="yyyy 年 MM 月 dd 日"
                          value-format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>
        <el-form-item label="结束日期">
          <el-date-picker type="date" placeholder="选择日期" v-model="end_time" style="width: 100%;"
                          format="yyyy 年 MM 月 dd 日"
                          value-format="yyyy-MM-dd"></el-date-picker>

        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer" style='padding:0px;margin:5px'>
        <el-button @click="shoujulogdeposit3 = false">取 消</el-button>
        <el-button type="success" @click="exportHospitalDoctorInfo">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal='false' :title="item2.name" center :visible.sync="shoujulogdeposit5">
      <el-form>
        <el-form-item label="截止日期">

          <el-date-picker type="date" placeholder="选择日期" v-model="start_time" style="width: 100%;"
                          format="yyyy 年 MM 月 dd 日"
                          value-format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer" style='padding:0px;margin:5px'>
        <el-button @click="shoujulogdeposit5 = false">取 消</el-button>
        <el-button type="success" @click="exportHospitalDoctorInfo">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :fullscreen="true" :close-on-click-modal='false' v-if="!datalist2.length==0" :title="item2.name" center
               :visible.sync="shoujulogdeposit">
      <el-card class="box-card" v-for="(item,index) in datalist2" :key="index">
        <div slot="header" class="clearfix">
          <h3>医生: {{ item.doctor_name }} | 总费用：{{ item.money }}</h3>
          <!-- <span> </span> -->
        </div>

        <el-row :gutter='20' v-if="!item.lists==0" style="font-size:14px">
          <el-col :span="4" v-for="(it,i) in item.lists" :key="i">
            {{ it.cate_name }} : {{ it.money }}
          </el-col>
        </el-row>
      </el-card>
      <div slot="footer" class="dialog-footer" style='padding:0px;margin:5px'>
        <el-button @click="shoujulogdeposit = false">取 消</el-button>

      </div>
    </el-dialog>

  </div>
</template>

<script>
import exl from "@/assets/exl.png"
import jqaxios from "./http"

export default {
  name: "baobiao",
  data() {
    return {
      exl: exl,
      http: process.env.VUE_APP_BASE_API,
      datalist: [{
        name: '医生核算报表',
        url: '/statistic/getDoctorCashInfo',
        url2: "/statistic/exportHospitalDoctorInfo",
        chakan: true,
        daochu: true
      }, {
        name: '在院病人费用核算',
        url: '/statistic/getDoctorCashInfoV2',
        url2: "/statistic/exportHospitalDoctorInfoV2",
        chakan: true,
        daochu: false,
        bxy:true
      },
        {
          name: '住院病人核算',
          url: '/statistic/getHospitalMemberCash',
          url2: "/statistic/exportHospitalMemberCash",
          chakan: true,
          daochu: true

        },
        {
          name: '病案首页',
          url2: '/upload/exportHospitalInfo',
          chakan: false,
          daochu: true
        },
        {
          name: '押金记录',
          url2: '/statistic/exportDepositOrder',
          chakan: false,
          daochu: true
        },
        {
          name: '检查治疗费用',
          url2: '/statistic/exportSysFeeItem',
          chakan: false,
          daochu: false,
          bxy:true
        },
        {
          name: '检查治疗费用(按月导)',
          url2: '/statistic/exportSysMonthFeeItem',
          chakan: false,
          daochu: true,
          bxy:false
        },

      ],
      datalist2: [],
      start_time: '',
      end_time: '',
      shoujulogdeposit3: false,
      shoujulogdeposit5: false,
      shoujulogdeposit: false,
      item2: {},
      index: 1
    }
  },
  methods: {
    exportHospitalDoctorInfo() {
      var that = this
      var data_t = {
        start_time: this.start_time,
        end_time: this.end_time
      }
      if (this.index == 1) {
        jqaxios.get(this.http + this.item2.url, data_t).then(res => {
          if (res.code == 200) {
            //  that.loading.close();
            console.log(res.data)
            this.datalist2 = res.data
            this.shoujulogdeposit3 = false
            this.shoujulogdeposit = true
            // window.open(this.$http + "/" + res.data.file_url);
          }
        })
      } else {
        jqaxios.get(this.http + this.item2.url2, data_t).then(res => {
          if (res.code == 200) {
            if (res.data) {
              console.log(res.data)
              window.open(this.$http + "/" + res.data.file_url);
            } else {
              window.open(this.$http + "/" + res.file_path);

            }
            this.shoujulogdeposit3 = false
            this.shoujulogdeposit5 = false
          }
        })
      }

      //  that.loading = that.$loading({
      //   lock: true,
      //   text: "正在下载中.....",
      //   background: "rgba(0, 0, 0, 0.7)"
      // });

    },
    updowd(item) {
      console.log(item)
      this.index = 1
      this.item2 = item
      this.shoujulogdeposit3 = true


    },
    updowd2(item) {
      this.index = 2
      this.item2 = item
      this.shoujulogdeposit3 = true
    },
    updowd3(item) {
      this.index = 2
      this.item2 = item
      this.shoujulogdeposit5 = true
    }
  },
  components: {}
}
</script>

<style lang="scss" scoped>
.el-card > > > .el-card__header {
  padding: 0px !important;
}
</style>
